import QtQuick 2.8
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import QtWeChat 1.0
import "./controls"

Page {
    id: root

    property WeChatRoomModel model

    padding: 0
    background: Item {}

    RowLayout {
        anchors.fill: parent
        spacing: 0

        ChatRoomBar {
            id: contactBar
            Layout.fillHeight: true
            model: root.model
            onCurrentIndexChanged: {
                chatMsg.model = root.model.currentRoom.messages
            }
        }

        ChatMessage {
            id: chatMsg
            Layout.fillWidth: true
            Layout.fillHeight: true
            onSendMsg: {
                if(root.model.currentRoom) {
                    root.model.currentRoom.sendMsg(msg)
                }
            }
        }
    }
}
